//
//  DeviceTypeListItemVM.swift
//  kxf
//
//  Created by LNS2 on 2024/4/21.
//

import Foundation
import UIKit

class DeviceTypeListItemVM: UIView {
    
    let selfHeight = kFitWidth(102)
    
    override init(frame:CGRect){
        super.init(frame: CGRect.init(x: 0, y: frame.origin.y, width: SCREEN_WIDHT, height: selfHeight))
        self.backgroundColor = .clear
        self.isUserInteractionEnabled = true
        
        initUI()
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    lazy var whiteView : UIView = {
        let vi = UIView()
        vi.isUserInteractionEnabled = true
        vi.layer.cornerRadius = kFitWidth(12)
        vi.clipsToBounds = true
        vi.backgroundColor = .white
        
        return vi
    }()
    lazy var imgView : UIImageView = {
        let img = UIImageView()
        img.layer.cornerRadius = kFitWidth(8)
        img.clipsToBounds = true
        
        return img
    }()
    lazy var nameLabel : UILabel = {
        let lab = UILabel()
        lab.textColor = .black
        lab.font = .systemFont(ofSize: 14, weight: .medium)
        lab.isUserInteractionEnabled = true
        
        return lab
    }()
    lazy var numberLabel : UILabel = {
        let lab = UILabel()
        lab.textColor = WHColor_16(colorStr: "666666")
        lab.font = .systemFont(ofSize: 12, weight: .regular)
        lab.isUserInteractionEnabled = true
        
        return lab
    }()
    lazy var arrowImgView : UIImageView = {
        let img = UIImageView()
        img.isUserInteractionEnabled = true
        img.setImgLocal(imgName: "icon_right_gray")
        
        return img
    }()
}

extension DeviceTypeListItemVM{
    func initUI(){
        addSubview(whiteView)
        whiteView.addSubview(imgView)
        whiteView.addSubview(nameLabel)
        whiteView.addSubview(numberLabel)
        whiteView.addSubview(arrowImgView)
        
        setConstrait()
    }
    func setConstrait() {
        whiteView.snp.makeConstraints { make in
            make.top.equalTo(kFitWidth(10))
            make.centerX.lessThanOrEqualToSuperview()
            make.width.equalTo(kFitWidth(343))
            make.height.equalTo(kFitWidth(92))
        }
        imgView.snp.makeConstraints { make in
            make.left.equalTo(kFitWidth(15))
            make.top.equalTo(kFitWidth(13))
            make.width.equalTo(kFitWidth(48))
            make.height.equalTo(kFitWidth(60))
        }
        nameLabel.snp.makeConstraints { make in
            make.left.equalTo(kFitWidth(77))
            make.top.equalTo(kFitWidth(14))
        }
        numberLabel.snp.makeConstraints { make in
            make.left.equalTo(nameLabel)
            make.top.equalTo(nameLabel.snp.bottom).offset(kFitWidth(15))
        }
        arrowImgView.snp.makeConstraints { make in
            make.right.equalTo(kFitWidth(-14))
            make.centerY.lessThanOrEqualToSuperview()
            make.width.height.equalTo(kFitWidth(22))
        }
    }
    
}
